﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LogHelper
{
    public class Log
    {
        public void AddLog(string ms)
        {
            try
            {
                if (!Directory.Exists("D:\\运行日志"))
                {
                   var s=  Directory.CreateDirectory(@"D:\\运行日志");
                   
                    // 文件夹存在的处理逻辑

                }
                else
                {
                    if (!File.Exists("D:\\运行日志\\" + $"{DateTime.Now.Year.ToString()}年{DateTime.Now.Month.ToString()}月{DateTime.Now.Day.ToString()}日.txt"))
                    {
                       var s=  File.Create("D:\\运行日志\\" + $"{DateTime.Now.Year.ToString()}年{DateTime.Now.Month.ToString()}月{DateTime.Now.Day.ToString()}日.txt") ;
                        s.Close();
                         
                    }
                    else
                    {

                        var s = File.AppendText("D:\\运行日志\\" + $"{DateTime.Now.Year.ToString()}年{DateTime.Now.Month.ToString()}月{DateTime.Now.Day.ToString()}日.txt");
                        s.WriteLine(ms+"---"+DateTime.Now.ToString());
                        s.Close();
                       
                    }
                }
            }
            catch(Exception ex)
            { 
            }
          
           
            
        }
    }
}
